//
//  ReleaseDynamicCollectionViewCell.m
//  GLGW_Shoping
//
//  Created by whx on 2018/12/12.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "ReleaseDynamicCollectionViewCell.h"

@interface ReleaseDynamicCollectionViewCell ()
@property (nonatomic,strong)GLGWImageView *backImageView;
@property (nonatomic,strong)GLGWButton *deletBtn;

@end

@implementation ReleaseDynamicCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        GLGWView * bankgroundView = [[GLGWView alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(3), kHeightProportion_In_iPhoneTriploid(3), kWidthProportion_In_iPhoneTriploid(95), kHeightProportion_In_iPhoneTriploid(95)) inSuperView:self];
        bankgroundView.backgroundColor = [UIColor whiteColor];
        bankgroundView.layer.cornerRadius = 6;
        bankgroundView.clipsToBounds = YES;
        
        GLGWImageView *goodsImageView = [[GLGWImageView alloc] initWithImageName:@"pp" inSuperView:bankgroundView];
        goodsImageView.backgroundColor = kRandomColor;
        [goodsImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.bottom.equalTo(bankgroundView);
        }];
        goodsImageView.layer.masksToBounds = YES;
        goodsImageView.layer.cornerRadius = 6;
        self.backImageView = goodsImageView;
        
        GLGWButton *btn = [[GLGWButton alloc] initInSuperView:bankgroundView];
//        [btn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
        [btn setBackgroundColor:kRandomColor];
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(bankgroundView);
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(29) + kHeightProportion_In_iPhoneTriploid(6)));
            make.bottom.equalTo(bankgroundView).offset(kHeightProportion_In_iPhoneTriploid(6));

        }];
        [btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        self.deletBtn = btn;
    }
    return self;
}

- (void)btnAction:(GLGWButton *)sender
{
    if (self.BlockDeletPhoto) {
        self.BlockDeletPhoto(self.index);
    }
}

- (void)setBackImg:(UIImage *)backImg
{
    _backImg = backImg;
    self.backImageView.image = backImg;
}

- (void)setHideDeleBtn:(BOOL)hideDeleBtn
{
    _hideDeleBtn = hideDeleBtn;
    self.deletBtn.hidden = hideDeleBtn;
}


@end
